package br.usp.ime.ingpos.modelo.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.RequestScoped;
import br.com.caelum.vraptor.util.hibernate.SessionCreator;
import br.usp.ime.ingpos.modelo.Inscricao;
import br.usp.ime.ingpos.modelo.Interesse;

@Component
@RequestScoped
public class InteresseDAO
    extends
        AbstractDaoImpl<Long,Interesse>
{
    public InteresseDAO(
        final SessionCreator sessionCreator )
    {
        super( sessionCreator );
    }

    public Interesse procuraInteresse(
    	final Long idProfessor,
        final Long idInscricao )
    {
        List<Interesse> relacoesDeInteresse = findByCriteria( Restrictions.and(Restrictions.eq( "idOrientador", idProfessor ), Restrictions.eq( "idInscricao", idInscricao ) ) );

        if( relacoesDeInteresse.isEmpty() )
            return null;

        return relacoesDeInteresse.get( 0 );
    }
    
    public List<Interesse> filtraPorOrientadorID(
        	final Long idProfessor )
        {
            List<Interesse> relacoesDeInteresse = findByCriteria( Restrictions.eq( "idOrientador", idProfessor ) );

            return relacoesDeInteresse;
        }
}
